<?php class ComHelloControllerPost extends AnSekitMediumController {

	public function __construct(KConfig $config)
	{
		parent::__construct($config);								
	}
	
	public function _actionBrowse($context)
	{

	     $data = $context->data;
	     $owner = $data->actor ; //the owner fetched from the oid happend in the AnSekitMediumController
	     $owner->posts->order('creationTime','DESC');
	}	

	protected function _actionAdd($context)
	{
		$data  = $context->data;
		$owner = $data->actor;
		$post  = $data->actor->posts->add(array(
			'application'		=> $this->getApplication(),
			'author'			=> $this->getViewer(),
			'openToComment'		=> true,
			'owner'				=> $owner,
			'title'				=> "Hello" ,
			'body'				=> $data->property->body
		));
		
		$data->post = $post;
		
		if( AnDomain::getContext()->save() )
		{
			return true;
		}
		
		return false;				
	}
		
}
